In [4]:
# Importando os módulos necessários
import numpy as np
from pandas import Series, DataFrame
import pandas as pd
import json
In [3]:
# Exemplo de um objeto JSON (JavaScript Object Notation):
json_obj = """
{ "zoo_animal": "Lion",
"food": ["Meat", "Veggies", "Honey"],
"fur": "Golden",
"clothes": null,
"diet": [{"zoo_animal": "Gazelle", "food":"grass", "fur": "Brown"}]
}
"""
In [5]:
data = json.loads(json_obj)
In [6]:
data
Out[6]:
In [7]:
# para converter o objeto para json novamente usamos o método dump do mudulo json
json.dumps(data)
Out[7]:
In [8]:
dframe = DataFrame(data['diet'])
In [9]:
dframe
Out[9]:
In [ ]: